package edu.neu.swc.commerce.conf;

import com.alibaba.cloud.sentinel.annotation.SentinelRestTemplate;
import com.alibaba.csp.sentinel.annotation.SentinelResource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

/**
 * <h1>开启服务间的调用保护，需要给 restTemplate 做一个包装</h1>
 */
@Slf4j
@Configuration
public class SentinelConfig {

    /**
     * <h2>Sentinel包装</h2>
     */
    @Bean
//    @SentinelRestTemplate(
//            fallback = "handleFallback",
//            fallbackClass = RestTemplateExceptionUtil.class,
//            blockHandler = "handleBlock",
//            blockHandlerClass = RestTemplateExceptionUtil.class
//    )
    public RestTemplate restTemplate(){
        return new RestTemplate(); //可以对其做一些业务相关的配置
    }
}
